package com.aaa.controller.api;

import com.aaa.entity.DictData;

import com.aaa.service.DictDataService;
import com.aaa.vo.DictTypeVo;
import com.aaa.vo.Result;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@RequestMapping("/system/api/dict/data")
public class DictDataControllerApi {
    @Autowired
    private DictDataService dictDataService;

    @GetMapping("findByType/{type}")
    public Result<List<DictData>> list(@PathVariable String type){
        return dictDataService.findByType(type);
    }
    @GetMapping("cacheAsync")
    public Result<String> cacheAsync(){
        return dictDataService.cacheAsync();
    }

    //分页查询
    @PostMapping("searchDict/{currentPage}/{pageSize}")
    public Result<IPage<DictData>> searchDict(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody DictTypeVo dictVo
    ){
        return dictDataService.findByConditions(currentPage,pageSize, dictVo);
    }
}
